//
//  UITextField+PlaceHolder.m
//  BuDeJie
//
//  Created by 陈恒均 on 2018/1/25.
//  Copyright © 2018年 小码哥. All rights reserved.
//

#import "UITextField+PlaceHolder.h"
#import <objc/message.h>

@implementation UITextField (PlaceHolder)

+(void)load
{
    Method method1 = class_getInstanceMethod(self, @selector(setPlaceholder:));
    
    Method method2 = class_getInstanceMethod(self, @selector(setXmg_Placeholder:));
    
    method_exchangeImplementations(method1, method2);

}

-(void)setXmg_Placeholder:(NSString *)placeholder
{
    [self setXmg_Placeholder:placeholder];
    
    self.placeHolderColor = self.placeHolderColor;
}

-(void)setPlaceHolderColor:(UIColor *)placeHolderColor
{
    
    objc_setAssociatedObject(self, @"placeholderColor", placeHolderColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    UILabel *placeholderLabel = [self valueForKeyPath:@"placeholderLabel"];
    placeholderLabel.textColor = placeHolderColor;
    
   
}

-(UIColor *)placeHolderColor{
    return  objc_getAssociatedObject(self, @"placeholderColor");
}

@end
